/***************************************************************************
 *   Copyright (C) 2009 by Marian Skvarek   *
 *   skvarek.marian@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef EASYSCORE_CORECBARVIEW_H
#define EASYSCORE_CORECBARVIEW_H

#include "CGraphicsRectItem.h"
#include "CRemoveBarControl.h"

class QGraphicsLineItem;

using namespace easyscore::view::utils;

namespace easyscore
{
	namespace core
	{

		class CBar;

		/**
		A view class for CBar class.
		
			@author Marian Skvarek <skvarek.marian@gmail.com>
		*/		
		class CBarView : public CGraphicsRectItem
		{
//Members
			protected:
				CBar *mModel;
				int mSuspended;
				
                                CRemoveBarControl *mRemoveBarControl;
				QGraphicsLineItem* mBarSeparatorLine;
				
//Accessors
			public:
				CBar *getModel() const { return mModel; }
				void setSuspended ( bool value ) { mSuspended += value ? 1 : -1; }
				bool getSuspended() const { return mSuspended; }

//Constructors, Destructors & Initialization
			public:
				CBarView ( CBar *model );
				void initialize();
				
				void clear();
                                virtual ~CBarView();

//Overrides
			protected:
				void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
				void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );

//Public methods
			public:
				void update();
				void refreshLayout();
	
				
//Protected methods
			protected:
				int calculateBarWidth();

		};
		
	}//namespace core
}//namespace easyscore

#endif
